//---------------------------------------------------------------------
// Author: jachymko
//
// Description: Wmi class name handler
//
// Creation Date: Jan 8, 2007
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

using BGShell.PowerShell.Commands;
using BGShell.PowerShell.TabExpansion.Caches;

namespace BGShell.PowerShell.TabExpansion.Handlers
{
    internal sealed class WmiClassHandler : TabExpansionHandler
    {
        public WmiClassHandler(GetTabExpansionCommand command)
            : base(command)
        {

        }

        public override bool TryExpand(string line, string word)
        {
            if (_pattern.IsMatch(word))
            {
                WriteExpansions(WmiClassCache.Instance.Expand(word));
            }

            return true;
        }

        private static readonly Regex _pattern = new Regex("(?i)^(Win32_|CIM_)");
    }
}
